<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>localStorage</title>
</head>
<body>
    <h1>localStorage</h1>
    <button onclick="addData()">存数据</button>
    <button onclick="getData()">查数据</button>
    <button onclick="deleteData()">删数据</button>
    <button onclick="clearData()">清空数据</button>
 
    <script>
        function addData(){
            localStorage.setItem('name','lisi')
            localStorage.setItem('msg','hello')
        }
        function getData(){
            console.log(localStorage.getItem('name'))
            
        }
        function deleteData(){
            localStorage.removeItem('name')
        }
        function clearData(){
            localStorage.clear()
        }
    </script>
</body>
</html>